//
//  PP_AlipayAccountUpdateViewController.m
//  PPDL
//
//  Created by 王洋 on 2019/11/4.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "PP_AlipayAccountUpdateViewController.h"

@interface PP_AlipayAccountUpdateViewController ()
@property (weak, nonatomic) IBOutlet UITextField *alipayNameTF;

@property (weak, nonatomic) IBOutlet UITextField *alipayAccountTF;

@property (nonatomic, assign) BOOL isWait;

@end

@implementation PP_AlipayAccountUpdateViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initView];

}

- (void)initView {

    self.isWait = NO;
    self.title = @"输入支付宝提现账号";
}

- (void)request_WithDrawApply {
    
    self.isWait = YES;
    NSDictionary *dic = @{}.mutableCopy;
    [dic setValue:self.amount forKey:@"amount"];
    [dic setValue:@"2" forKey:@"clientType"];// 客户端类型 1.微信小程序 2.APP 5.公众号
    [dic setValue:@"2" forKey:@"type"];// 转账方式 0银行卡打款 1微信转账 2支付宝转账
    [dic setValue:self.alipayAccountTF.text forKey:@"aliAccount"];
    [dic setValue:self.alipayNameTF.text forKey:@"aliRealName"];
    
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,TT_MEMBER_WITHDRAW_APPLY_V2];
    
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        
        self.isWait = NO;
        if ([data isKindOfClass:[NSDictionary class]]) {
            
            NSString * code = [data valueForKey:@"code"];
            if ([code isEqualToString:@"200"]) {
                
                [self.navigationController popToRootViewControllerAnimated:YES];
                [self alert:[data valueForKey:@"msg"]];
                
            } else {
                
                [self alert:[data valueForKey:@"msg"]];
            }
            
        } else {
            
        }
        
        
    } FailedBlock:^(NSError * _Nonnull error) {
        self.isWait = NO;

    }];
}

- (IBAction)alipayWithDraw:(id)sender {
    
    if (!self.alipayAccountTF.text.length) {
        
        [self alert:@"请输入支付宝账号"];
    } else {
        
        if (!self.alipayNameTF.text.length) {
            
            [self alert:@"请输入支付宝绑定的姓名"];
        } else {
            
            [self request_WithDrawApply];
        }
    }
    
    
}


@end
